package logic

import (
	"context"
	"rent-ease/models"
	"rent-ease/userrpc/internal/svc"
	"rent-ease/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DetailLogic {
	return &DetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DetailLogic) Detail(in *userrpc.DetailRequest) (*userrpc.DetailResponse, error) {
	// todo: add your logic here and delete this line
	var house models.House
	models.DB.Debug().Where("id=?", in.Id).First(&house)
	return &userrpc.DetailResponse{
		Id:    int64(house.ID),
		Name:  house.Name,
		Price: float32(house.Price),
		Num:   int64(house.Num),
	}, nil
}
